<?php
class TestController extends Controller
{
	public function actionContractEarned($contractid)
	{
		ContractEarnedUtil::getEarnedData($contractid);
	}

	public function actionMakeEarnedReport($startDate){
		$criteria = new CDbCriteria();
		$criteria->addCondition('(contractstartdate <=:inputDate and contractenddate>=:inputDate)');
		$criteria->params['inputDate'] = $startDate;
		$contractList = Contracts::model()->findAll($criteria);
		$total=0;

		$count = 0;
		foreach($contractList as $contract)
		{				
			if($contract->custno != '0000235'){
				$total +=ContractEarnedUtil::getEarnedData($contract,$startDate);
				$count++;
			}
		}
		echo $count;exit;
		echo 'Total '.$total. ' records are created';
	}

	public function actionMakeEarnedReportById($contractId,$startDate)
	{
		$contract 	= Contracts::model()->findByPk($contractId);
		$records 	= ContractEarnedUtil::getEarnedData($contract,$startDate);
	
	}

	public function actionMakeAdjustmentById($contractId,$date){
		$contract= Contracts::model()->findByPk($contractId);
		ContractEarnedUtil::writeAdjustmentToSingleContract($contract,$date);
	}
}